<?php
/**
 * Introduction: APP登录注册、接口、找回密码等接口类
 * @author: 杨陈鹏
 * @date: 2016/4/7 23:00
 * @email: yangchenpeng@cdlinglu.com
 */
namespace WeChat\Controller\Sign;


use Think\Controller;

class IndexController extends Controller
{

    /**
     * Introduction: 用户登录
     * @author: 杨陈鹏
     * @date: 2016/4/7 23:00
     * @email: yangchenpeng@cdlinglu.com
     */
    public function login()
    {

        $logic = D('Common/Member', 'Logic');

        $data = I('post.data');

        outPut($logic::login($data));


    }   

    /**
     * Introduction: 用户注册
     * @author: 杨陈鹏
     * @date: 2016/4/7 23:00
     * @email: yangchenpeng@cdlinglu.com
     */
    public function register()
    {

        $logic = D('Common/Member', 'Logic');

        $data = I('post.data');

        outPut($logic::create($data));


    }


    /**
     * Introduction: 客户端自动登录
     * @author: 杨陈鹏
     * @date: 2016/4/8 10:48
     * @email: yangchenpeng@cdlinglu.com
     */
    public function autologin()
    {

        $uuid = I('post.uuid');

        if (!$uuid)
            outPut(['code' => 300, 'msg' => '网络错误!']);

        $logic = D('Common/Member', 'Logic');

        if ($data = $logic::getOneData(['uuid' => $uuid])) {

            session('uid', $data['uid']);
            outPut(['code' => 200, 'msg' => '登录成功', 'data' => $data]);

        }

        outPut(['code' => 300, 'msg' => '登录失败!']);

    }

    /**
     * Introduction: 检测手机号码是否存在
     * @author: 杨陈鹏
     * @date: 2016/4/8 10:48
     * @email: yangchenpeng@cdlinglu.com
     */
    public function checkMobile()
    {

        $mobile = I('post.mobile');

        $logic = D('Common/Member','Logic');

        outPut($logic::checkAppMobile($mobile));

    }

    /**
     * Introduction: 检测手机号码是否存在
     * @author: 杨陈鹏
     * @date: 2016/4/8 10:48
     * @email: yangchenpeng@cdlinglu.com
     */
    public function bind()
    {

        $data = I('post.data');

        $logic = D('Common/ThirdAuth', 'Logic');

        outPut($logic::bind($data));

    }

    /**
     * Introduction: 找回密码
     * @author: 杨陈鹏
     * @date: 2016/4/8 10:48
     * @email: yangchenpeng@cdlinglu.com
     */
    public function forgotten()
    {

        $logic = D('Common/Member','Logic');

        $data = I('post.data');

        outPut($logic::findPassword($data));


    }

}